package com.lagou.sqlSession;

import com.lagou.config.XMLConfigBuilder;
import com.lagou.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory builder(InputStream inputStream) throws PropertyVetoException, DocumentException {
        //1、使用dom4j解析配置文件，将解析出来的内容封装到config中。
        Configuration configuration=new XMLConfigBuilder().parseConfig(inputStream);

        //2.创建sqlsessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;

    }

}
